<template>
  <div>
    <el-table border v-loading="loading" :data="issuelineList">
      <el-table-column label="产品物料编码" width="160px" align="center" prop="itemCode" :show-overflow-tooltip="true"/>
      <!--      <el-table-column label="产品物料名称" width="120px" align="center" prop="itemName" :show-overflow-tooltip="true"/>-->
      <el-table-column label="规格型号" width="120px" align="center" prop="specification" :show-overflow-tooltip="true"/>
      <!--      <el-table-column label="单位" align="center" prop="unitOfMeasure" :show-overflow-tooltip="true"/>-->
      <el-table-column label="数量" align="center" prop="quantityIssued"/>
      <el-table-column label="批次号" width="180px" align="center" prop="batchCode" :show-overflow-tooltip="true"/>
      <el-table-column label="仓库名称" width="130px" align="center" prop="warehouseName" :show-overflow-tooltip="true"/>
      <el-table-column label="库区名称" width="150px" align="center" prop="locationName" :show-overflow-tooltip="true"/>
      <el-table-column label="库位名称" width="180px" align="center" prop="areaName" :show-overflow-tooltip="true"/>
      <!--      <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true"/>-->
    </el-table>

    <pagination
      class="noprint"
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listIssueline } from "@/api/mes/wm/issueline";

export default {
  name: "Issueline",
  props: {
    optType: null,
    issueId: null,
    warehouseId: null,
    locationId: null,
    areaId: null,
    workorderId: null,
    itemCode: null,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产领料单行表格数据
      issuelineList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 100,
        issueId: this.issueId,
        workorderId: this.workorderId,
        itemId: null,
        itemCode: this.itemCode,
        itemName: null,
        specification: null,
        unitOfMeasure: null,
        quantityIssued: null,
        batchCode: null,
        warehouseId: null,
        warehouseCode: null,
        warehouseName: null,
        locationId: null,
        locationCode: null,
        locationName: null,
        areaId: null,
        areaCode: null,
        areaName: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        itemCode: [
          {required: true, message: "产品物料不能为空", trigger: "blur"}
        ],
        quantityIssued: [
          {required: true, message: "领料数量不能为空", trigger: "blur"}
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询生产领料单行列表 */
    getList() {
      this.loading = true;
      listIssueline(this.queryParams).then(response => {
        this.issuelineList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        lineId: null,
        issueId: this.issueId,
        itemId: null,
        itemCode: null,
        itemName: null,
        specification: null,
        unitOfMeasure: null,
        quantityIssued: null,
        batchCode: null,
        warehouseId: null,
        warehouseCode: null,
        warehouseName: null,
        locationId: null,
        locationCode: null,
        locationName: null,
        areaId: null,
        areaCode: null,
        areaName: null,
        remark: null,
        attr1: null,
        attr2: null,
        attr3: null,
        attr4: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },


  }
};
</script>
